# Copyright 2024 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

load(
    "//cc_toolchain:defs.bzl",
    "pw_cc_feature",
    "pw_cc_feature_constraint",
    "pw_cc_feature_set",
    "pw_cc_flag_set",
    "pw_cc_mutually_exclusive_category",
)
load(":test_features.bzl", "test_features")

package(default_visibility = ["//cc_toolchain/tests:__subpackages__"])

pw_cc_feature(
    name = "foo",
    enabled = True,
    feature_name = "foo",
    flag_sets = ["//cc_toolchain/tests/flag_sets:foo"],
)

pw_cc_feature(
    name = "bar",
    enabled = True,
    feature_name = "bar",
    flag_sets = [
        "//cc_toolchain/tests/flag_sets:bar",
        "//cc_toolchain/tests/flag_sets:env",
    ],
)

pw_cc_feature(
    name = "baz",
    enabled = True,
    feature_name = "baz",
    flag_sets = ["//cc_toolchain/tests/flag_sets:baz"],
)

pw_cc_feature(
    name = "conflict",
    enabled = True,
    feature_name = "foo",
)

pw_cc_feature_set(
    name = "foobar",
    all_of = [
        ":foo",
        ":bar",
    ],
)

pw_cc_feature(
    name = "implies",
    enabled = True,
    feature_name = "implies",
    implies = [":foobar"],
)

pw_cc_feature(
    name = "requires",
    enabled = True,
    feature_name = "requires",
    requires_any_of = [
        ":foobar",
        ":baz",
    ],
)

pw_cc_feature(
    name = "supports_pic",
    enabled = True,
    feature_name = "supports_pic",
    overrides = "//features/well_known:supports_pic",
)

pw_cc_feature(
    name = "supports_pic_no_override",
    enabled = True,
    feature_name = "supports_pic",
)

pw_cc_feature(
    name = "implies_supports_pic",
    enabled = True,
    feature_name = "implies_supports_pic",
    implies = ["//features/well_known:supports_pic"],
)

pw_cc_feature_constraint(
    name = "foo_not_baz",
    all_of = [":foo"],
    none_of = [":baz"],
)

pw_cc_feature_constraint(
    name = "foo_only",
    all_of = [":foo_not_baz"],
    none_of = [":bar"],
)

pw_cc_flag_set(
    name = "constrained_flags",
    actions = ["//actions:c_compile"],
    flags = ["blah"],
    requires_any_of = [
        ":foo_not_baz",
        ":bar",
    ],
)

pw_cc_feature(
    name = "constrained",
    enabled = True,
    feature_name = "constrained",
    flag_sets = [":constrained_flags"],
)

pw_cc_mutually_exclusive_category(
    name = "category",
)

pw_cc_feature(
    name = "primary_feature",
    enabled = True,
    feature_name = "primary_feature",
    mutually_exclusive = [":category"],
)

pw_cc_feature(
    name = "mutex_provider",
    enabled = True,
    feature_name = "mutex_provider",
    mutually_exclusive = [":category"],
)

pw_cc_feature(
    name = "mutex_label",
    enabled = True,
    feature_name = "mutex_label",
    mutually_exclusive = [":primary_feature"],
)

test_features(
    name = "test_features",
)
